<p>This rule raises an issue when a getter or setter method recursively accesses the same property it defines, which causes infinite recursion.</p>
<h2>Why is this an issue?</h2>
<p>When a getter or setter method accesses the same property it defines, it creates infinite recursion that leads to a stack overflow error.</p>
<p>For example, when you write <code>get bar() { return this.bar; }</code>, calling the getter triggers itself repeatedly because
<code>this.bar</code> invokes the same getter method. This creates an endless loop that consumes all available stack memory.</p>
<p>The same problem occurs with setters: <code>set bar(value) { this.bar = value; }</code> will call itself infinitely when you try to assign a value
to the property.</p>
<p>This type of error crashes your application at runtime with a "Maximum call stack size exceeded" error. It’s particularly dangerous because the
code looks correct at first glance, making it easy to miss during code reviews.</p>
<h3>What is the potential impact?</h3>
<p>The application will crash with a stack overflow error when the problematic getter or setter is accessed. This can lead to service downtime and
poor user experience, especially if the property is accessed frequently in the application flow.</p>
<h3>How to fix?</h3>
<p>Use a different property name, typically with an underscore prefix to indicate it’s private, or access a different property that holds the actual
value.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const user = {
  get name() {
    return this.name; // Noncompliant
  },
  set name(value) {
    this.name = value; // Noncompliant
  }
};
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const user = {
  get name() {
    return this._name;
  },
  set name(value) {
    this._name = value;
  }
};
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/no-accessor-recursion.md">no-accessor-recursion</a> </li>
  <li> MDN - get - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get">Documentation for getter syntax in
  JavaScript</a> </li>
  <li> MDN - set - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set">Documentation for setter syntax in
  JavaScript</a> </li>
  <li> MDN - Maximum call stack size exceeded - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Too_much_recursion">Information about stack overflow errors in
  JavaScript</a> </li>
</ul>
